package org.yhx.learning.verticle;/*
 * Copyright (C), 2024, bigmoon
 * FileName:
 * Author:   bigmoon
 * Date:     2024/9/4 18:10
 * Description: //模块目的、功能描述
 * History: //修改记录
 * &lt;author&gt;      &lt;time&gt;      &lt;version&gt;    &lt;desc&gt;
 * 修改人姓名             修改时间            版本号                  描述
 */

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Context;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * Context.runOnContext 是执行在eventloop 线程上
 */
public class MixedThreading extends AbstractVerticle {

    private static final Logger LOGGER = LoggerFactory.getLogger(MixedThreading.class);


    @Override
    public void start() throws Exception {
        Context context = vertx.getOrCreateContext();

        new Thread(()->this.run(context)).start();

    }

    private void run( Context context){

//        是执行在eventloop 线程上
        context.runOnContext((obj)->{
            LOGGER.info("这个是在java 线程执行任务");
        });
    }

    public static void main(String[] args) {

        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new MixedThreading());
    }


}
